#pragma once
#include "editor.h"
#include "control.h"


// CWPXmlFileView

class CWPXmlFileView : public CDockablePane, public i_data_listener
{
	DECLARE_DYNAMIC(CWPXmlFileView)

	void AdjustLayout();
	void ExpandSubTree(CTreeCtrl& aTree, HTREEITEM aItem);
public:

	enum{
		DM_ADD_IMPORT		= 0,
		DM_ADD_RESOURCE,
		DM_DEL_CURRENT,
		DM_DEL_CUR_REF,
		DM_CREATE_REFERENCE = 0x1000,
		DM_ADD_REFERENCE	= 0x2000,
		DM_ADD_CONTROL		= 0x3000,
		DM_ADD_EVENT		= 0x4000
	};

	typedef map<int, wstring> CmdMap;
	CmdMap	m_cmdMap;

	CWPXmlFileView();
	virtual ~CWPXmlFileView();

	CTreeCtrl m_ctlImpEveResTree;
	CTreeCtrl m_ctlRefTree;
	CTreeCtrl m_ctlCtlTree;

	void FillXMLData();
	void FillImpEveResTree(i_data* aImp, i_data* aEve, i_data* aRes);
	void FillRefTree(i_data* aRef);
	void FillCtlTree(i_data* aCtl);

	//i_data_listener
	wchar_t* get_listener_name(){return L"xml_file_view";}
	void on_event(s_data_event& e);

	void FillAControlNode(control* aCtl, HTREEITEM hItem);
protected:
	DECLARE_MESSAGE_MAP()
public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	void OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult);
	void OnNMclkTree1(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
};


